package com.kgo.jwt.config;

import com.kgo.jwt.filter.JWTFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author keepgoon
 * @Description: TODO
 * @date 2019/3/110:23
 */
@Configuration
public class WebConfig {
    @Bean
    public FilterRegistrationBean someFilterRegistration1() {
        //新建过滤器注册类
        FilterRegistrationBean registration = new FilterRegistrationBean();
        // 添加我们写好的过滤器
        registration.setFilter( new JWTFilter());
        Map<String,String> init_params = new HashMap <>();
        init_params.put("loginUrl","/login.html");
        init_params.put("ignoreUrl","/login,/login.html");
        registration.setInitParameters(init_params);
        // 设置过滤器的URL模式
        registration.addUrlPatterns("/*");
        return registration;
    }

}
